<?
if (!defined('MODULE_FILE')){
	die ("cant access file directly!");
}

$mid	= $_GET['mid'];
$smid	= $_GET['smid'];
$emp_id = $_SESSION['SESS_MEMBER_ID'];

require_once 'classes/Base/BaseSpecilizations.class.php';
require_once 'classes/Specilizations.class.php';

$objSpecilization 	= new BaseSpecilizations();
$objSpecilizations 	= new Specilizations();

$arrobj = $objSpecilizations->fetchAllSpecilizations();

?>
<html>
<head>
<?php require_once 'commonJS.php'; ?>
</head>
<body>
	<div style="margin-left:20px; margin-top: 10px;">
		<p>
			<a class="btn btn-outline btn-primary btn-xs" id="active" href="modules.php?file=specialization&mid=<? echo $mid;?>&smid=<? echo $smid;?>" >Add Specialization</a>
			<a class="btn btn-outline btn-primary btn-xs" id="active" href="modules.php?file=view_specialization&type=view&mid=<? echo $mid;?>&smid=<? echo $smid;?>" >View All Specialization</a>
		</p>
	</div>
<div class="col-lg-8">
<div class="panel panel-primary">
<div class="panel-heading"><i class="fa fa-bell fa-fw"></i>Add Specilizations</div>
<div class="panel-body">

<form METHOD="POST" action="modules.php?file=insert_specialization&type=insert&mid=<? echo $mid; ?>&smid=<? echo $smid; ?>" id="formSubmit" name="formSubmit" >
	
		<table width="80%" cellspacing="0" cellpadding="3">

			<tr><td height="10" colspan="2"></td></tr>
			<tr valign="top">
				<td class="mandatory" width="220">Specialization ID</td>
				<td>
				<?php
				$intSpecializationId = NULL;
				$strName 			= NULL;
				$strDescription 	= NULL;
				$boolIsPublished 	= true;
				$intOrderNumber 	= NULL;
				
				if( true == isset( $_GET['Specialization_id'] ) && true == valStr( $_GET['Specialization_id'] ) ) {
					$intSpecializationId = $_GET['Specialization_id'];
					
					$objSpecilization = $objSpecilizations->fetchSpecilizationsById( $_GET['Specialization_id'] );
					
					if( true == valObj( $objSpecilization, 'BaseSpecilizations' ) ) {
						$strName 				= $objSpecilization->getName();
						$strDescription 		= $objSpecilization->getDescription();
						$boolIsPublished 		= $objSpecilization->getIsPublished();
						$intOrderNumber 		= $objSpecilization->getOrderNumber();
					}
				} else if( true == valObj( $objSpecilization, 'BaseSpecilizations' ) ) {
					$intSpecializationId = $objSpecilization->fetchNextId();
				}
				?>
					<input id="Specialization_id" Name="Specialization_id" type="text" class="validate[required]" style="width:100px;" readonly="readonly" value="<?php echo $intSpecializationId;?>"> <label>Auto generated</label>
			  </td>
			</tr>
			<tr><td height="10" colspan="2"></td></tr>
			<tr><td height="10" colspan="2"></td></tr>
			<tr valign="top">
				<td class="mandatory" width="220">Name</td>
				<td>
					<input id="name" Name="name" type="text" class="validate[required]" style="width:202px;" value="<?php echo $strName; ?>">
				</td>
			</tr>
			<tr><td height="10" colspan="2"></td></tr>
			<tr valign="top">
				<td class="mandatory" width="220">Description</td>
				<td>
					<input id="description" Name="description" type="text" class="validate[required]" style="width:202px;" value="<?php echo $strDescription; ?>">
				</td>
			</tr>
			<tr><td height="10" colspan="2"></td></tr>
			<tr valign="top">
				<td class="mandatory" width="220">Is Published</td>
				<td>
					<input id="is_published" Name="is_published" type="text" style="width:202px;" value="<?php echo $boolIsPublished; ?>">
				</td>
			</tr>
			<tr><td height="10" colspan="2"></td></tr>
			<tr valign="top">
				<td class="mandatory" width="220">Order No</td>
				<td>
					<input id="OrderNumber" Name="OrderNumber" type="text" class="validate[required]" style="width:202px;" value="<?php echo $intOrderNumber; ?>">
				</td>
			</tr>
			<tr><td height="10" colspan="2"></td></tr>
			<tr valign="top">
				<td class="mandatory" width="220">&nbsp;</td>
				<td>
					<?php
						if( true == isset( $_GET['Specialization_id'] ) && true == valStr( $_GET['Specialization_id'] ) ) {
							echo "<input type=hidden name=operation value=update>";
							echo "<input type=submit value=UPDATE id=Submit name=Submit>";
						} else {
							echo "<input type=hidden name=operation value=insert>";
							echo "<input type=submit value=SUBMIT id=Submit name=Submit>";
						}
					?>
				</td> 				
			</tr>
		</table>
	</form>
</div>
</div>
</div>	
</body>
</html>